package com.youkeda.test.threadpool;

import java.util.concurrent.Future;

/**
 * 继续
 *
 * @author CoderXshuai
 */
public class Animal implements Runnable {
    private String name;
    private int speed;
    private int length = 10;
    private static Future<?> future;

    @Override
    public void run() {
        length -= speed;
        System.out.println(name + "跑了" + speed + "米，距离终点还有" + length + "米");
        if (length == 0) {
            System.out.println(name + "到达终点");
            future.cancel(true);
        }
    }

    public Animal(String name, int speed) {
        this.name = name;
        this.speed = speed;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getLength() {
        return length;
    }

    public void setLength(int length) {
        this.length = length;
    }
}
